package com.zqxq.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

/**
 * Copyright(C) 2018  Rights Reserved.
 * <p>
 * FileName: ListUtil
 * <p>
 * Description:
 * <p>
 * History:
 * 版本号    作者    日期
 * 1.0      sxm    2019/6/10
 */

public class ListUtil {

    public ListUtil() {
    }

    public static List<String> toList(String str) {
        if(StringUtils.isBlank(str)) {
            return null;
        } else {
            str = StringUtils.replace(str, "，", ",");
            String[] array = StringUtils.split(str, ",");
            List<String> list = Arrays.asList(array);
            return list;
        }
    }

    public static List<String> toList(String str, String eparatorChar) {
        if(StringUtils.isBlank(str)) {
            return null;
        } else {
            String[] array = StringUtils.split(str, eparatorChar);
            List<String> list = Arrays.asList(array);
            return list;
        }
    }

    public static String toStr(List<String> list) {
        if(list != null && !list.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            Iterator var3 = list.iterator();

            while(var3.hasNext()) {
                String _str = (String)var3.next();
                sb.append(_str).append(",");
            }

            sb.deleteCharAt(sb.length() - 1);
            return sb.toString();
        } else {
            return "";
        }
    }

    public static String toStr(String[] list) {
        if(list != null && list.length != 0) {
            StringBuilder sb = new StringBuilder();
            String[] var5 = list;
            int var4 = list.length;

            for(int var3 = 0; var3 < var4; ++var3) {
                String _str = var5[var3];
                sb.append(_str).append(",");
            }

            sb.deleteCharAt(sb.length() - 1);
            return sb.toString();
        } else {
            return "";
        }
    }

    public static boolean isEmpty(List list) {
        return list == null || list.isEmpty();
    }

    public static boolean isNotEmpty(List list) {
        return list != null && !list.isEmpty();
    }
}
